﻿@using System.Data;
@using ZoomLa.BLL
@using ZoomLa.SQLDAL
@using ZoomLa.Common
@model ZoomLa.SQLDAL.SQL.PageSetting
@functions{
    B_Arrive avBll = new B_Arrive();
    public string IsDisabled(DataRow dr)
    {
        if (DataConverter.CLng(dr["state"]) == 10 || DataConverter.CDate(dr["EndTime"]) < DateTime.Now) { return "disabled"; }
        return "";
    }
    public string GetMoneyRegion(DataRow dr)
    {
        double min = DataConvert.CDouble(dr["MinAmount"]);
        double max = DataConvert.CDouble(dr["MaxAmount"]);
        return avBll.GetMoneyRegion(min, max);
    }
}
@{
    Model.page_wrap_start = "<li class='clearfix'></li></ul><div class='text-center'>";
    Model.page_wrap_end = "</div>";
    Model.Check = false;
}
@{
    if (Model.dt.Rows.Count < 1)
    {
        <div id="empty_div">
            <div class="alert alert-info">当前没有优惠券</div>
        </div>
    }
    else
    {
        <div id="EGV">
            <ul class="list-unstyled">
                @foreach (DataRow dr in Model.dt.Rows)
                {
                    <li class="a_item boxborder @IsDisabled(dr)">
                        <div class="type">
                            <div>
                                <i class="fa fa-rmb"></i>
                                <span class="amount">@Convert.ToInt32(dr["AMount"])</span>
                                <span class="region">@GetMoneyRegion(dr)</span>
                            </div>
                            <div class="r_gray r_item">@dr["ArriveName"]</div>
                            <div class="r_gray r_item">@Convert.ToDateTime(dr["AgainTime"]).ToString("yyyy.MM.dd")-@Convert.ToDateTime(dr["EndTime"]).ToString("yyyy.MM.dd")</div>
                        </div>

                        @if (IsDisabled(dr) == "disabled")
                        {
                            <div class="opbtns">
                                <b></b>
                                @if (Convert.ToInt32(dr["state"]) == 10)
                                {<a>已经使用</a> }
                                else if (DataConverter.CDate(dr["EndTime"]) < DateTime.Now)
                                { <a>已经过期</a>}
                            </div>
                        }
                        else
                        {
                            <div class="opbtns" style="cursor:pointer;" onclick="window.open('/Class_2/Default.aspx');" title="使用优惠卷">
                                <b></b>
                                <a>立即使用</a>
                            </div>
                        }
                    </li>
                }
                @Html.Partial("_page", Model)
        
                
                </div>
    }
}